package net.comic.entities

class AlterPage {
	//	Attributes
	String 	title
	String 	description
	String 	imagePath
	boolean rateable = true
	boolean disabled = false
	
	Date 	dateCreated
	Date 	lastUpdated
	
	static 	transients = ['rate']
	
	
	//	DB Relations & Constraits
	static belongsTo = 	[homePage:		Page, 
	                   	 createdBy:		User]
						 
	static hasMany =	[comentarios:	Comment,
	                	 ratings:		Rate]
	
	
	//	Other Methods
	String getRate() {
		//	Calculem la mitja de les puntuacions rebudes fins ara
		Float p = 0
		if(ratings){
			ratings.each(){ p += it.rate }
			p = p / ratings.count()
		}
		return p	//TODO: comprvar si esta linea hace falta
	}
}